﻿<!--#include file="../inc/easp/easp.asp"-->
<!--#include file="../inc/conn1.asp"-->
<!--#include file="../inc/checklogin.asp"-->
<!--#include file="../inc/easyide.asp"-->
<% CheckLogin("../index.asp") %>
<%
    '鏉冮檺涓嶅鐩存帴璺冲埌棣栭〉
	If Session("Authority")<>"0" Then
		Response.Write "<script type=""text/javascript"">top.location.href='../main.asp';</script>"
	end if				
%>
<%
  dim y_id,operate
  y_id = Easp.Get("y_id")
  operate = Easp.Get("op")
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  <%
    If request.QueryString("action") <> "custom" then
      Select Case request.QueryString("page")
	    Case "country"
		  Easp.w "Add Country"
		Case "province"
		  Easp.w "Add Province"
		Case "city"
		  Easp.w "Add City"
	  End Select
	End if
  %>
</title>
<link rel="stylesheet" type="text/css" href="../css/theme.css" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript">
	var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
	document.writeln('<link rel="stylesheet" type="text/css" href="../css/' + StyleFile + '">');
	
	function chkv(obj)
    { 
        top.location.href="add.asp?selectedIndex="+obj.selectedIndex;
    } 
    
    function Rrederict()
    { 
        top.location.href="Group.asp";
    } 
</script>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
</head>
<body>
<div id="container">
	<div id="header">
    <div id="divAccount" style="float:right;">
        <a href="../user/account.asp" style="color:white">Account</a>&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="../inc/logout.asp" style="color:white">Logout</a>
      </div>
		<h2>
	<%
    If request.QueryString("action") <> "custom" then
      Select Case request.QueryString("page")
	    Case "country"
		  Easp.w "Add Country"
		Case "province"
		  Easp.w "Add Province"
		Case "city"
		  Easp.w "Add City"
	  End Select
	End if
  %>
  </h2>
		<div id="topmenu">
			<ul>
				<li><a href="../main.asp">Home</a></li>
				<li class="current"><a href="#">Country</a></li>
				<li><a href="../holiday/index.asp">Holiday</a></li>
				<li><a href="../Times/index.asp">Times</a></li>
				<li><a href="../wallboard/index.asp">WallBoard</a></li>
				<%
				   If Session("Authority")="0" Then 
				       Response.Write("<li><a href='../user/index.asp'>User</a></li>")
				   End if
				%>
				<li><% If Session("Passed")=true Then %><a href="../inc/logout.asp">Logout</a><% End If %></li>
			</ul>
		</div>
	</div>
	<div id="top-panel">
		<div id="panel">
			<ul>
				<li><a href="<%=request.serverVariables("Http_REFERER")%>" class="goback">GoBack</a></li>
			</ul>
		</div>
	</div>
	<div id="wrapper">
		<%
		
		dim page
		dim pid
		dim yid
		dim uid
		dim cid
		dim relt
		dim gid
	    dim cityname
	    dim countryname
	    dim provincename
	    dim groupname

	    'dim a
	    'a =request.QueryString("action")
	    
	    'response.write("<Script language=JavaScript>alert('"&a&"');</Script>")
	    
		If request.QueryString("action") = "custom" Then

            'page=request.QueryString("page")
            'response.write("<Script language=JavaScript>alert('"&page&"');</Script>")
            
            If request.QueryString("page") = "country" Then
                dim rscountry
			     page="country"
			     uid=0
			     countryname=request.form("txtCountryName")
			     yid=request.form("yid")
			     gid=request.form("gid")
			     
			     '插入国家表
		         relt=Easp.db.AddRecord("Country",Array("u_id:"&uid,"CountryName:"&countryname))
		         
		         '查询刚插入的国家号
		         rscountry=Easp.db.GetRecordBySQL("Select max(y_id) as id  From Country")
		         
		         if Not Easp.IsN(rscountry) Then
		            yid=rscountry("id")
		         end if
		        ' response.write("<Script language=JavaScript>alert('"&page&"');</Script>")
		         '插入组国家关系表
		         relt=Easp.db.AddRecord("GroupCountry",Array("GroupID:"&gid,"CountryID:"&yid))
		         
		        Response.Redirect "index.asp"
		    elseif request.QueryString("page") = "province" Then
		        page="province" 
		        response.write("<Script language=JavaScript>alert('"&request.form("yid")&"');</Script>")
		        if(request.form("yid")<>"") then
		        
                 yid=CStr(request.form("yid"))
		         end if
		          
		         provincename=request.form("txtProvinceName")
		         
		         'response.write("<Script language=JavaScript>alert('"&provincename&"');</Script>")
		         'response.write("<Script language=JavaScript>alert('"&yid&"');</Script>")
		         
		         relt=Easp.db.AddRecord("province",Array("y_id:"&yid,"provincename:"&provincename))
		         
		         'response.write("<Script language=JavaScript>alert('"&relt&"');</Script>")
                 Response.Redirect "Province.asp?action=det&yid="&yid

		    elseif request.QueryString("page") = "city" Then
			    page="city" 
			    pid=request.form("pid")
		        yid=request.form("yid")
                cityname=request.form("txtCityName")
                'response.write("<Script language=JavaScript>alert('"&pid&"');</Script>")
                'response.write("<Script language=JavaScript>alert('"&cityname&"');</Script>")
		        relt=Easp.db.AddRecord("city",Array("cityname:"&cityname,"p_id:"&pid))
		        Response.Redirect "City.asp?action=det&pid="&pid
		    End if

			If relt<>0 Then
				 response.write("<Script language=JavaScript>alert('Add  Succeed');</Script>")
			else
				 response.write("<Script language=JavaScript>alert('Add  Failed');</Script>")
			End If
	
		else
		    
		    If request.QueryString("page") = "country" Then
			     page="country"
			     yid=request.QueryString("yid") 
			     gid=request.QueryString("gid")
			     countryname=request.QueryString("countryname") 
			     
		    elseif request.QueryString("page") = "province" Then
		        yid=request.QueryString("yid") 
		        pid=request.QueryString("pid") 
		        provincename=request.QueryString("provincename") 
		        page="province" 

            'response.write("<Script language=JavaScript>alert('"&page&"');</Script>")
		    'response.write("<Script language=JavaScript>alert('"&yid&"');</Script>")

		    elseif request.QueryString("page") = "city" Then
			    page="city" 
			    pid=request.QueryString("pid") 
		        cityname=request.QueryString("cityname") 
		    End if
		   
	    End If    
		
		%>
		<div id="content" align="center">	
				<div id="loginbox" align="center" style="margin: 10px 45px; width: 496px;">					
					<form name="form1" id="form4" action="add.asp?action=custom&page=<%=page%>" method="post">
					 <% 
                           dim rsgroup,sql
                           
                           set rsgroup= Easp.db.GetRecordBySQL("SELECT Group.ID, Group.GroupName FROM [Group] where 1=1 and Group.ID="&gid) 
    					   
                           If Not Easp.IsN(rsgroup) Then
                            
                               'Easp.wc "<br/>"
                               'Easp.wc "<select name='group' id='group' style='width:110px;' onchange='chkv(this)'>"
                               While not rsgroup.eof
                                    groupname=rsgroup(1)
                                    'response.write("<Script language=JavaScript>alert('"&rsgroup(1)&"');</Script>")
						  	          'Easp.wc "<option value='" & rsgroup("ID") & "'>"& rsgroup("GroupName") &"</option>"
						  	        rsgroup.MoveNext()
					           Wend
					           'Easp.wc "</select>"
					           'Easp.wc "<input type='hidden' value='' name='stext'/> "
                           End if 
                           
                           
                          
                        %>
					  <%
					   'If page = "city" Then
						  Easp.w "<input type='hidden' name='pid' value='" & pid & "' />"
					      Easp.w "<input type='hidden' name='yid' value='" & yid & "' />"
						  Easp.w "<input type='hidden' name='cid' value='" & cid & "' />"
						  Easp.w "<input type='hidden' name='gid' value='" & gid & "' />"
					    'End if
					  %>
					  <div id="divCountry"  name="divCountry">
					  
					  <% 
					  if page="country" then
					  %>
					  <table>
					    <tr>
						  <td width="228">
						    Group Name:
						  </td>
						  <td>
					        <input name='txtGroup' type='text' id='txtGroup' value="<%=groupname %>"/>
						  </td>
						</tr>
					  </table>
					  
					  <%
					  end if
					   %>
					  <br/>
					    <table>
					      <tr>
							  <%
							    Select Case page
								  Case "country"
								    
								
								    Easp.w "<td>Country Name:</td>"
									Easp.w "<td><input name='txtCountryName' type='text' id='txtCountryName' /></td>"
								  Case "province"
								    Easp.w "<td>Province Name:</td>"
									Easp.w "<td><input id='txtProvinceName' name='txtProvinceName' type='text' /></td>"
								  Case "city"
								    Easp.w "<td>City Name:</td>"
									Easp.w "<td><input id='txtCityName' name='txtCityName' type='text' /></td>"
								End select							      
							  %>						    
						  </tr>						  
						  <tr>
						      <%
							    Select Case page
								  Case "country"
                                    Easp.w "<td><input type='hidden' name='Country' value='" & Session("Country") & "' /></td>"
						            Easp.w "<td></td>"
								  Case "province"
								    'Easp.w "<td><input type='hidden' name='pid' value='" & pid & "' /></td>"
						            'Easp.w "<td><input type='hidden' name='yid' value='" & yid & "' /></td>"
								  Case "city"
								    Easp.w "<td><input type='hidden' name='Country' value='" & Session("Country") & "' /></td>"
     						        Easp.w "<td></td>"
								End select							        
							  %>
						  </tr>
						  <tr>
						      <%
							    Select Case page
								  Case "country"
                                    Easp.w "<td><input class='btn' type='submit' value='Save' /></td>"
						            Easp.w "<td><input name='reset' type='reset' class='btn' value='Reset' /></td>"
								  Case "province"
								    Easp.w "<td>"
									Easp.w "<input type='hidden' name='Country' value='" & Session("Country") & "' />"
									Easp.w "<input class='btn' type='submit' value='Save' />"
									Easp.w "</td>"
									Easp.w "<td><input name='reset' type='reset' class='btn' value='Reset' /></td>"
								  Case "city"
								    Easp.w "<td><input class='btn' type='submit' value='Save' /></td>"
									Easp.w "<td><input name='reset' type='reset' class='btn' value='Reset' /></td>"
								End select
							    
							  %>
						  </tr>
					    <table>					    
					  </div>
					</form>	           
	</div>
	<!--#include file="../inc/footer.asp" -->
</div>

</body>
</html>
